export {}

// type对象注解

type Person = {
    name: string,
    age?: number
}

let p: Person = {
    name: 'John',
    age: 36
}
console.log(p)

// 交叉类型 模拟继承

// 父接口
type GoodsType = {
    id: string,
    price: number
}

// 子继承接口
type DisGoodsTypes = GoodsType & {
    disPrice: number
}

let goods: DisGoodsTypes = {
    id: '123',
    price: 123,
    disPrice: 12
}
console.log(goods)

// 练习
type Data = {
    title: string,
    content: string
}

type Article = {
    code: number,
    msg: string,
    data: Data
} 

let obj: Article = {
    code: 13,
    msg: 'ok',
    data: {
        title: '橙色',
        content: '666'
    }
}
console.log(obj)